package com.plm.mqshequ.config;

import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/**
 * 验证码生成配置
 */
@Configuration
public class KaptchaConfig {

    @Bean
    public DefaultKaptcha producer() {
        Properties properties = new Properties();
        properties.put("kaptcha.border", "no");
        properties.put("kaptcha.textproducer.font.color", "black");//字体颜色
        properties.put("kaptcha.textproducer.char.space", "5");//字符间距
        properties.put("kaptcha.textproducer.font.size", "30");//字体大小
        properties.put("kaptcha.image.height", "38");//图片高
        properties.put("kaptcha.image.width", "150");//图片宽
        Config config = new Config(properties);
        DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
        defaultKaptcha.setConfig(config);
        return defaultKaptcha;
    }

}
